<template>
  <MoMask class="mask">
    <div class="main-box">
      <div class="mes-header">Message</div>
      <div class="mes-message">{{this.msg}}</div>
      <div class="mes-contral">
        <div class="confirm">
          <img :src="confirmI" @mouseover="confrimHover" @mouseout="confrimUp" @click="confirmOk" />
        </div>
        <div class="cancel">
          <img :src="cancelI" @mouseover="cancelHover" @mouseout="cancelUp" @click="cancelOk" />
        </div>
      </div>
    </div>
  </MoMask>
</template>
<script>
import $ from "jquery";
import MoMask from "../mask";
import ConfirmImg from "../../../../assets/SAOIcon/icon/ok_normal.png";
import CancelImg from "../../../../assets/SAOIcon/icon/cancel_normal.png";
import ConfirmImgHover from "../../../../assets/SAOIcon/icon/ok_hover.png";
import CancelImgHover from "../../../../assets/SAOIcon/icon/cancel_hover.png";
export default {
  name: "SaoAlert",
  props: ["msg", "confirmImg", "cancelImg"],
  data() {
    return {
      confirmI: ConfirmImg,
      cancelI: CancelImg,
      height: $(window).height() + "px"
    };
  },
  beforeUpdate: function() {},
  computed: {},
  watch: {},
  mounted: function() {
    $(".main-box").css("transform", "scale(1)");
  },
  methods: {
    confrimHover: function() {
      this.confirmI = ConfirmImgHover;
    },
    confrimUp: function() {
      this.confirmI = ConfirmImg;
    },
    cancelHover: function() {
      this.cancelI = CancelImgHover;
    },
    cancelUp: function() {
      this.cancelI = CancelImg;
    },
    confirmOk: function() {
      let timer = setTimeout(() => {
        this.$emit("close");
        clearTimeout(timer);
        timer = null;
      }, 300);
      this.$emit("comfirm");
      $(".main-box").css("transform", "scale(0)");
    },
    cancelOk: function() {
      let timer = setTimeout(() => {
        this.$emit("close");
        clearTimeout(timer);
        timer = null;
      }, 300);
      $(".main-box").css("transform", "scale(0)");
      this.$emit("cancel");
    }
  },
  components: { MoMask }
};
</script>
<style lang="less" scoped>
.main-box {
  width: 400px;
  height: 260px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 5px;
  box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  transition: all 0.4s;
  transform: scale(0);
  .mes-header {
    height: 30%;
    width: 100%;
    box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 32px;
  }
  .mes-message {
    width: 100%;
    height: 40%;
    background-color: rgba(100, 100, 100, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 14px;
  }
  .mes-contral {
    height: 30%;
    width: 100%;
    box-shadow: 0px -5px 15px rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: space-evenly;
    align-items: center;
    .confirm {
      width: 40px;
      height: 40px;
      background-size: cover;
      cursor: pointer;
      &:hover {
        background-size: cover;
      }
      img {
        width: 100%;
        height: 100%;
        background-size: cover;
      }
    }
    .cancel {
      width: 40px;
      height: 40px;
      background-size: cover;
      cursor: pointer;
      &:hover {
        background-size: cover;
      }
      img {
        width: 100%;
        height: 100%;
        background-size: cover;
      }
    }
  }
}
</style>